{extend name="template/base" /}
{block name="content"}
<!--select2样式 start -->
<link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />
<br><br><br>
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" style="padding-left: 80px;padding-right: 80px" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="ids" value="{$ids ?? ''}">
        <input type="hidden" name="edit2" value="1">

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>酒店名称：</label>
            <div class="formControls col-xs-6 col-sm-6">
                {$data.hotel_name}
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>结算账户：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select name="account" id="account" class="input-text" style="width: 200px" datatype="*" onclick="change_account(this)" nullmsg="结算账户不能为空">
                    {if empty($data['account'])}
                        <option value="">请选择结算账户</option>
                    {/if}
                    {foreach $hotel_account as $vo2}
                        <option {if ($vo2['account'] == $data['account'])} selected {/if} value="{$vo2.account}-{$vo2.account_name}-{$vo2.account_bank}">{$vo2.account}</option>
                    {/foreach}
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>账号名称：</label>
            <div id="account_name" class="formControls col-xs-6 col-sm-6">
                <div id="account_name_p"><p >{$data.account_name?:'暂无信息'}</p><input type="hidden" name="account_name" value="{$data.account_name?:''}"></div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3"><span class="c-red">*</span>开户行：</label>
            <div id="account_bank" class="formControls col-xs-6 col-sm-6">
                <div id="account_bank_p"><p >{$data.account_bank?:'暂无信息'}</p><input type="hidden" name="account_bank" value="{$data.account_bank?:''}"></div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script>

    function change_account(e) {
        var val = $(e).val()
        console.log('va',typeof(val))
        console.log('val',val)
        if(val==''){
            if($("#account_name").children().length > 0){
                $("#account_name_p").remove()
            }
            if($("#account_bank").children().length > 0){
                $("#account_bank_p").remove()
            }
            console.log('children',$("#account_name").children())
            $("#account_name").append('<div id="account_name_p"><p >暂无信息</p><input type="hidden" name="account_name" value=""></div>');
            $("#account_bank").append('<div id="account_bank_p"><p >暂无信息</p><input type="hidden" name="account_bank" value=""></div>');
        }else{
            var arr = val.split('-');
            if($("#account_name").children().length > 0){
                $("#account_name_p").remove()
            }
            if($("#account_bank").children().length > 0){
                $("#account_bank_p").remove()
            }
            console.log('children',$("#account_name").children())
            $("#account_name").append('<div id="account_name_p"><p >'+arr[1]+'</p><input type="hidden" name="account_name" value="'+arr[1]+'"></div>');
            $("#account_bank").append('<div id="account_bank_p"><p >'+arr[1]+'</p><input type="hidden" name="account_bank" value="'+arr[2]+'"></div>');
        }
    }
    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                if(ret.code == 0){
                    layer.msg(ret.msg, {
                        time: 2000,
                    },function () {
                        window.parent.location.reload(); //刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引\
                        parent.layer.close(index)
                    });
                }else{
                    ajax_progress(ret);
                }

            }
        });
        //用户select2 js部分 start
        var route_id = $("#route_id").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        var hotel_id = $("#hotel_id").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        var hotel_room_type = $("#hotel_room_type").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });

    })
</script>
{/block}